import turtle
import math

# 设置画布和画笔
screen = turtle.Screen()
screen.title("Q版雷电将军绘图")
screen.setup(800, 800)
screen.bgcolor("white")

t = turtle.Turtle()
t.speed(0)
t.hideturtle()

# 定义颜色
HAIR_COLOR = "#5a3a7a"
SKIN_COLOR = "#f8d8c0"
EYE_COLOR = "#8a51e6"
CLOTH_COLOR_1 = "#a06cd5"
CLOTH_COLOR_2 = "#e2c7f5"
CLOTH_COLOR_3 = "#5a3a7a"
BUTTERFLY_COLOR = "#b08bd9"
FLORAL_COLOR = "#e6c8ff"
BOW_COLOR = "#d2691e"
PURPLE_ACCENT = "#8a51e6"

# 辅助函数：移动到指定位置
def move(x, y):
    t.penup()
    t.goto(x, y)
    t.pendown()

# 绘制头发
def draw_hair():
    # 绘制头发轮廓
    move(0, 100)
    t.fillcolor(HAIR_COLOR)
    t.begin_fill()
    t.setheading(90)
    t.circle(150, 180)
    t.setheading(-90)
    t.forward(300)
    t.end_fill()

    # 绘制头发左侧细节
    move(-100, 50)
    t.begin_fill()
    t.circle(80, 120)
    t.setheading(-30)
    t.forward(100)
    t.setheading(-150)
    t.forward(80)
    t.end_fill()

    # 绘制头发右侧细节
    move(100, 50)
    t.begin_fill()
    t.circle(-80, 120)
    t.setheading(210)
    t.forward(100)
    t.setheading(330)
    t.forward(80)
    t.end_fill()

# 绘制面部
def draw_face():
    # 绘制脸部
    move(0, -50)
    t.fillcolor(SKIN_COLOR)
    t.begin_fill()
    t.circle(80)
    t.end_fill()

    # 绘制左眼
    move(-40, 20)
    t.fillcolor(EYE_COLOR)
    t.begin_fill()
    t.circle(15)
    t.end_fill()

    # 绘制右眼
    move(40, 20)
    t.begin_fill()
    t.circle(15)
    t.end_fill()

    # 绘制左眼高光
    move(-35, 25)
    t.fillcolor("white")
    t.begin_fill()
    t.circle(5)
    t.end_fill()

    # 绘制右眼高光
    move(45, 25)
    t.begin_fill()
    t.circle(5)
    t.end_fill()

    # 绘制嘴巴
    move(0, -20)
    t.pencolor("#e09f80")
    t.setheading(-90)
    t.circle(10, 180)

# 绘制服饰
def draw_clothes():
    # 绘制上衣
    move(-60, -80)
    t.fillcolor(CLOTH_COLOR_1)
    t.begin_fill()
    t.setheading(0)
    t.forward(120)
    t.setheading(-90)
    t.forward(40)
    t.setheading(180)
    t.forward(120)
    t.setheading(90)
    t.forward(40)
    t.end_fill()

    # 绘制左侧袖子
    move(-60, -80)
    t.fillcolor(CLOTH_COLOR_2)
    t.begin_fill()
    t.setheading(-45)
    t.forward(50)
    t.setheading(-90)
    t.forward(30)
    t.setheading(135)
    t.forward(70)
    t.setheading(90)
    t.forward(10)
    t.end_fill()

    # 绘制右侧袖子
    move(60, -80)
    t.begin_fill()
    t.setheading(-135)
    t.forward(50)
    t.setheading(-90)
    t.forward(30)
    t.setheading(45)
    t.forward(70)
    t.setheading(90)
    t.forward(10)
    t.end_fill()

    # 绘制腰带
    move(-30, -80)
    t.fillcolor(CLOTH_COLOR_3)
    t.begin_fill()
    t.setheading(0)
    t.forward(60)
    t.setheading(-90)
    t.forward(20)
    t.setheading(180)
    t.forward(60)
    t.setheading(90)
    t.forward(20)
    t.end_fill()

    # 绘制蝴蝶结
    move(-10, -80)
    t.fillcolor(BOW_COLOR)
    t.begin_fill()
    t.setheading(45)
    t.forward(15)
    t.setheading(-45)
    t.forward(30)
    t.setheading(-135)
    t.forward(15)
    t.setheading(135)
    t.forward(30)
    t.end_fill()

# 绘制发饰
def draw_hair_accessory():
    # 绘制发簪
    move(-70, 120)
    t.fillcolor("#e6c8ff")
    t.begin_fill()
    t.setheading(0)
    t.forward(20)
    t.setheading(90)
    t.forward(40)
    t.setheading(180)
    t.forward(20)
    t.setheading(270)
    t.forward(40)
    t.end_fill()

    # 绘制花朵
    move(-65, 130)
    t.fillcolor(FLORAL_COLOR)
    t.begin_fill()
    for _ in range(6):
        t.circle(10, 120)
        t.left(60)
    t.end_fill()

# 绘制蝴蝶
def draw_butterflies():
    # 蝴蝶位置
    positions = [(-120, 40), (120, 20), (-100, -20), (100, -40)]
    for x, y in positions:
        move(x, y)
        t.fillcolor(BUTTERFLY_COLOR)
        t.begin_fill()
        t.setheading(45)
        t.circle(10, 90)
        t.setheading(135)
        t.circle(10, 90)
        t.setheading(225)
        t.circle(10, 90)
        t.setheading(315)
        t.circle(10, 90)
        t.end_fill()

# 绘制手臂装饰
def draw_arm_accessory():
    # 绘制手臂装饰主体
    move(70, -60)
    t.fillcolor(CLOTH_COLOR_3)
    t.begin_fill()
    t.setheading(0)
    t.forward(20)
    t.setheading(90)
    t.forward(30)
    t.setheading(180)
    t.forward(20)
    t.setheading(270)
    t.forward(30)
    t.end_fill()

    # 绘制手臂装饰上的紫色元素
    move(75, -50)
    t.fillcolor(PURPLE_ACCENT)
    t.begin_fill()
    t.circle(5)
    t.end_fill()

# 主函数：依次绘制各部分
def main():
    draw_hair()
    draw_face()
    draw_clothes()
    draw_hair_accessory()
    draw_butterflies()
    draw_arm_accessory()

if __name__ == "__main__":
    main()
    turtle.done()